<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>作业3</title>
</head>
<body>
<h1><pre>
import datetime
import functools

def logging(logfile):
    def log_decorator(fun):
        @functools.wraps(fun)
        def inner(*args, **kwargs):
            log = f"[{datetime.datetime.now()}] {fun.__name__} was called "
            print(log)
            with open(logfile, 'a') as fd:
                fd.write(log + '\n')

            return fun(*args, **kwargs)
        return inner
    return log_decorator

@logging("./log/test.log")
def fun1():
    pass
def fun2():
    pass

fun1()

fun2 = logging("./log/test.log") (fun2)
fun2()
</pre></h1>
</body>
</html>